;(function(undefined) {
    "use strict"
    var _global;

    function result(args,fn){
        var argsArr = Array.prototype.slice.call(args);
        if(argsArr.length > 0){
            return argsArr.reduce(fn);
        } else {
            return 0;
        }
    }
    var selectDataList = {
        columnsInit:function(){
            return  [
            	{
	                field: 'radio',
	                radio: true,
	                align: 'center',
	                valign: 'middle'
	            },
                {
                    title: '应用编码',
                    field: 'appCode',
                    sortable : true

                },
                {
                    title: '租户编码',
                    field: 'tenantCode',
                    sortable : true
                },
                {
                    title: '租户名称',
                    field: 'tenantName',
                    sortable : true
                }
            ]
        },
        gridInit:function(columns){
            return $("#dataTable").bootstrapTable({
            	columns: columns,
                striped: 'true',
                clickToSelect: true,
                classes: 'table table-hover qxttable table-com roletable',
                onClickRow:function(row, $element,field){
                     $("#dataTable").bootstrapTable("uncheckAll");
                }
            })
        },
        dataLoad:function(appCode,tenantCodes){
        	$("#dataTable").bootstrapTable("removeAll");
        	$("#dataTable").bootstrapTable("showLoading");
        	var args = {};
        	args.appCode = appCode;
        	args.tenantCodes = tenantCodes;
        	$$.ajax({
		        url:"/rest/BaseTenantBusiness/listForLogin",
		        suiteCode:"base",
		        data : args,
		        success : function(data){
		            $("#dataTable").bootstrapTable("load",data);
		            $("#dataTable").bootstrapTable("hideLoading");
		        }
		    });
        	return;
        }
    }
    // 将插件对象暴露给全局对象
    _global = (function(){ return this || (0, eval)('this'); }());
    if (typeof module !== "undefined" && module.exports) {
        module.exports = selectDataList;
    } else if (typeof define === "function" && define.amd) {
        define(function(){return selectDataList;});
    } else {
        !('plugin' in _global) && (_global.selectDataList = selectDataList);
    }
}());

function getSelectData(){
    var len = $("#dataTable input:checked").length;
    if (len == 0) {
        //未选中数据提示框
        layer.msg('请选择数据', {time:1000});
        return false;
    } else {
        var rows= $("#dataTable").bootstrapTable('getSelections');
        var rowIds = [];
        var ret={};
        return rows[0];
    }
}

function initData(appCode,tenantCodes){
	//渲染选择数据表格
    var columns = selectDataList.columnsInit();
    var table = selectDataList.gridInit(columns);
    selectDataList.dataLoad(appCode,tenantCodes);
}

$(function () {
    
});

